#include<iostream>
#include<cmath>
#include<unordered_map>
using namespace std;
typedef long long LL;
const int N = 1e6 + 10;
int primes[N];
bool st[N];
int cnt;
int n;
unordered_map<LL, int>mp;

void fun()
{
	for (int i = 2; i <= N - 1; i++) {
		if (!st[i]) {
			primes[++cnt] = i;
		}
		for (int j = 1; primes[j] <= (N - 1) / i; j++) {
			st[primes[j] * i] = 1;
			if (i % primes[j] == 0)break;
		}
	}
}
int main()
{
	fun();
	cin >> n;
	while (n--) {
		LL x;
		scanf("%lld", &x);
		LL m = sqrt(x);
		if (x < 4) {
			printf("NO\n");
			continue;
		}
		if (!st[m] && m * m == x) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	return 0;
}